package com.avricot.userinfo.os;

import com.avricot.userinfo.UserInfo;

public class OS {
    private OSName name;
    private String version = UserInfo.VERSION_UNKNOWN;

    public OS(final OSName name) {
	this.name = name;
    }

    public OS(final OSName name, final String version) {
	this(name);
	this.version = version;
    }

    public OSName getName() {
	return name;
    }

    public void setName(final OSName name) {
	this.name = name;
    }

    public String getVersion() {
	return version;
    }

    public void setVersion(final String version) {
	this.version = version;
    }

    @Override
    public String toString() {
	return "OS [name=" + name + ", version=" + version + "]";
    }

    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + ((name == null) ? 0 : name.hashCode());
	result = prime * result + ((version == null) ? 0 : version.hashCode());
	return result;
    }

    @Override
    public boolean equals(final Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	final OS other = (OS) obj;
	if (name != other.name)
	    return false;
	if (version == null) {
	    if (other.version != null)
		return false;
	} else if (!version.equals(other.version))
	    return false;
	return true;
    }
}
